package com.example.beanlife;

import com.example.beanlife.bean.Student;
import org.junit.Test;
import org.springframework.beans.factory.support.DefaultListableBeanFactory;

/**
 * ClassName:testRegisterBean
 * Package:com.example.beanlife
 * Description:
 *
 * @Author:ZhangXin
 * @Create:2023/5/9-9:50
 * @Version:v1.0
 */
public class testRegisterBean {
    @Test
    public void testRegisterBean() {
        Student student = new Student();
        System.out.println(student);
        //将自己new的这个对象交给spring容器来管理
        DefaultListableBeanFactory factory = new DefaultListableBeanFactory();
        factory.registerSingleton("studentBean",student);

        Object bean = factory.getBean("studentBean");
        System.out.println(bean);
    }
}
